#include <bits/stdc++.h>
#define ll long long
using namespace std;

const int Maxn=1e5+6;
int n,m;
int c[Maxn],t[Maxn],w[Maxn],llp;
ll g[Maxn],tot,kl[Maxn];
ll ans;

int main(){
    freopen("book.in","r",stdin);
    freopen("book.out","w",stdout);
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",&c[i]),llp+=c[i];
    for(int i=1;i<=n;i++) scanf("%d",&t[i]);
    for(int i=1;i<=n;i++) scanf("%d",&w[i]);
    cin>>m;

    if(llp<=21){
        for(int i=1;i<=n;i++)
            for(int j=1;j<=c[i];j++)
                g[++tot]=t[i],kl[tot]=w[i];
        for(int i=0;i<(1<<tot);i++){
            ll ret=0,rey=0;
            for(int j=0;j<tot;j++) if(i>>j&1) ret+=t[j+1],rey+=w[j+1];
            if(ret<=m) ans=max(ans,rey);
        }
        cout<<ans;
    }

    system("pause");
    return 0;
}